package com.cdu.guoxinan.www.smartcom.unit.model;

import lombok.Data;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

@Data
public class R {
    public final int code;
    private final String message;
    private final Object data;
    private final long count;
    @Contract(" -> new")
    public static @NotNull R ok() {
        return new R(0, "success", null, 0);
    }
    @Contract("_ -> new")
    public static @NotNull R ok(Object data) {
            return new R(0, "success", data, 1);
    }
    @Contract("_,_-> new")
    public static @NotNull R ok(Object data, long count) {
        return new R(0, "success", data, count);
    }
    @Contract("_-> new")
    public static @NotNull R error(String message) {
        return new R(500, message, null, 0);
    }

}
